﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Anatomikhuman;

namespace Pharmacy
{
    public partial class MainForm : Form
    {
        SQLaccess sql;
        public MainForm()
        {
            InitializeComponent();
            comboBox1.Items.Add("Название");
            comboBox1.Items.Add("Симтоми/Органи");
            comboBox1.Items.Add("Активное вичиство");
            comboBox1.Text = "Название";
            sql = new SQLaccess(@"../../../BaZa_Apteka.mdb");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FormA fa = new FormA();
            fa.ShowDialog();
            textBox1.Text = Anatomia.semtom(Anatomia.id);
        }

        private void MainForm_Load(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            int id = 0;
            for (int i = 0; i < comboBox1.Items.Count; i++)
            {
                if (comboBox1.Items[i].ToString() == comboBox1.Text)
                {
                    id = i;
                }
            }
            id++;
            DataTable t = sql.Searech(textBox1.Text, id);
            foreach (DataRow d in t.Rows)
            {
                double tmp = 0;
                Double.TryParse(d[0].ToString(), out tmp);
                listBox1.Items.Add(sql.NameLikarstvo((int)tmp));
            }
        }

        private void label5_Click(object sender, EventArgs e)
        {

        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string name = listBox1.Items[listBox1.SelectedIndex].ToString();
            //MessageBox.Show(listBox1.Items[listBox1.SelectedIndex].ToString());
            label4.Text = name;
            int id = sql.idLikarstva(name);
            label5.Text = sql.kol(id).ToString(); ;
            label7.Text = sql.forma(id);
            label9.Text = sql.prise(id).ToString();
            panel1.Visible = true;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            int id = sql.idLikarstva(label4.Text);
            sql.Sale(id);
            label5.Text = sql.kol(id).ToString(); ;
        }
    }
}
